<template>
  <div class="vueFormValidBox">
    <!-- <myForms :url="AccoutMsgObj.url" :span="12" ref="myForms" :data="accoutMsgFormData"></myForms> -->
    <vueForm
      ref="vueform"
      :span="12"
      :customData="customData"
      :formConfigData="formConfigData"
      @buttonClickCallback="buttonClick"
    >
      <h2 slot="slot">slot内容</h2>
    </vueForm>
  </div>
</template>

<script>
import vueForm from "@/components/vueForm/vueForm.vue";
import { LoadAccountConfigAxios } from "../js/accBookManaAE.js";

export default {
  name: "AccoutMsg",
  props: {
    CurrBookObj: {
      type: Object,
      default: function () {
        return {};
      },
    },
  },
  components: {
    vueForm,
  },
  data() {
    return {
      AccoutMsgFormList: [
        {
          guid: "guids11",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "text",
          name: "账簿编码：",
          columncode: "code",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 10,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids131",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "text",
          name: "账簿名称：",
          columncode: "name",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 11,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids2",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "select",
          name: "账簿类型：",
          columncode: "name",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 20,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids3",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "select",
          name: "启用状态：",
          columncode: "num",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 30,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids4",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "text",
          name: "银行：",
          columncode: "name",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 40,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids5",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "text",
          name: "银行账簿：",
          columncode: "name",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 50,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids6",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "select",
          name: "会计科目：",
          columncode: "Code",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 51,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids6",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "datePicker",
          name: "建账日期：",
          columncode: "Code",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 51,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids5",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "select",
          name: "是否日结：",
          columncode: "name",
          isvisiable: 1,
          requirement: 1,
          defaultvalue: null,
          colspannum: null,
          ordernum: 50,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids6",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "text",
          name: "资金性质：",
          columncode: "Code",
          isvisiable: 1,
          requirement: 0,
          defaultvalue: null,
          colspannum: null,
          ordernum: 51,
          appid: "uac",
          isedit: 1,
          config: null,
        },
        {
          guid: "guids6",
          key: "/uac/system/userset",
          tablecode: "fasp_t_causer",
          type: "text",
          name: "付款人：",
          columncode: "Code",
          isvisiable: 1,
          requirement: 0,
          defaultvalue: null,
          colspannum: null,
          ordernum: 51,
          appid: "uac",
          isedit: 1,
          config: null,
        },
      ],
      AccoutMsgObj: {
        url: "/afsp/index/addAccountBook",
      },
      formConfigData: {
        button: {
          textAlign: "textRight",
          options: [
            { name: "提交", action: "submit", isVisiable: true },
            { name: "查询", action: "select", isVisiable: true },
          ],
        },
        autoComplete: {
          options: [
            { label: "篮球23222", id: "篮球23" },
            { label: "足球7222", id: "足球7" },
          ],
        },
        checkbox: {
          multiple: true,
          options: [
            { label: "篮球", id: "111" },
            { label: "足球", id: "222" },
          ],
        },
        select: {
          multiple: true,
          options: [
            { label: "篮球", id: "111" },
            { label: "足球", id: "222" },
            { label: "乒乓球", id: "333" },
          ],
        },
        datePicker: {},
        quarterDatepicker: {},
        icon: {
          options: [
            { id: 1, className: "el-icon-delete" },
            { id: 2, className: "el-icon-s-tools" },
            { id: 3, className: "el-icon-phone" },
            { id: 4, className: "el-icon-eleme" },
          ],
        },
        treeModel: {
          multiple: true,
          options: [
            {
              id: 1,
              label: "一级 1",
              children: [
                {
                  id: 4,
                  label: "二级 1-1",
                  children: [
                    {
                      id: 9,
                      label: "三级 1-1-1",
                    },
                    {
                      id: 10,
                      label: "三级 1-1-2",
                    },
                  ],
                },
              ],
            },
            {
              id: 2,
              label: "一级 2",
              children: [
                {
                  id: 5,
                  label: "二级 2-1",
                },
                {
                  id: 6,
                  label: "二级 2-2",
                },
              ],
            },
            {
              id: 3,
              label: "一级 3",
              children: [
                {
                  id: 7,
                  label: "二级 3-1",
                },
                {
                  id: 8,
                  label: "二级 3-2",
                },
              ],
            },
          ],
        },
        switch: {
          activeValue: 1, // switch 打开时的值 [Boolean, String, Number]
          inactiveValue: 0,
        },
        input: {
          validator: (rule, value, callback) => {
            if (!value) {
              callback(new Error("请输入正确的值"));
            } else {
              callback();
            }
          },
        },
      },
      customData: [
        {
          code: "span1",
          title: "span框",
          isVisiable: true,
          type: "span",
          isDisabled: false,
        },
        {
          code: "autoComplete",
          title: "自动完成框 ",
          isVisiable: true,
          type: "autoComplete",
          isDisabled: false,
          isRequired: true,
        },
        {
          code: "checkbox",
          title: "复选框",
          isVisiable: true,
          type: "checkbox",
          isDisabled: false,
          fromSource: "checkbox",
        },
        {
          code: "checkboxBtn",
          title: "复选按钮",
          isVisiable: true,
          type: "checkboxBtn",
          isDisabled: false,
          fromSource: "checkbox",
        },
        {
          code: "datePicker",
          title: "日期框",
          isVisiable: true,
          type: "datePicker",
          isDisabled: false,
          isRequired: true,
          config: {
            validator: (rule, value, callback) => {
              if (!value) {
                console.log("value", value);
                callback(new Error("请输入正确的日期"));
              } else {
                callback();
              }
            },
          },
        },
        {
          code: "tree",
          title: "下拉树",
          isVisiable: true,
          type: "selectDialogTree",
          isDisabled: false,
          isRequired: true,
          fromSource: "checkbox",
        },
        {
          code: "icon",
          title: "图标",
          isVisiable: true,
          type: "icon",
          isDisabled: false,
        },
        {
          code: "input",
          title: "文本框",
          isVisiable: true,
          type: "input",
          isDisabled: false,
          isRequired: true,
        },
        {
          code: "counter",
          title: "计数器",
          isVisiable: true,
          type: "counter",
          isDisabled: false,
          isRequired: true,
        },
        {
          code: "quarterDatepicker",
          title: "季度框",
          isVisiable: true,
          type: "quarterDatepicker",
          isDisabled: false,
          isRequired: true,
        },
        {
          code: "radio",
          title: "单选框",
          isVisiable: true,
          type: "radio",
          isDisabled: false,
          fromSource: "checkbox",
        },
        {
          code: "radioBtn",
          title: "单选按钮",
          isVisiable: true,
          type: "radioBtn",
          isDisabled: false,
          fromSource: "checkbox",
        },
        {
          code: "select",
          title: "下拉框",
          isVisiable: true,
          // fromSource: "checkbox",
          type: "select",
          isDisabled: false,
          isRequired: true,
        },
        {
          code: "switch",
          title: "switch框",
          isVisiable: true,
          type: "switch",
          isDisabled: false,
        },
        {
          code: "treeModel",
          title: "弹框树",
          isVisiable: true,
          type: "treeModel",
          isDisabled: false,
          isRequired: true,
        },
        {
          code: "upload",
          title: "上传附件",
          isVisiable: true,
          type: "upload",
          isDisabled: false,
          isRequired: true,
        },
        {
          code: "slot",
          title: "slot内容",
          isVisiable: true,
          type: "slot",
          isDisabled: false,
        },
        {
          span: 24,
          code: "button",
          // title: "按钮",
          isVisiable: true,
          type: "button",
          isDisabled: false,
          labelWidth: "0",
        },
      ],
      accoutMsgFormData: {
        data: this.AccoutMsgFormList,
        form: this.AccoutMsgFormVal,
      },
      formObj: { span1: "" },
    };
  },
  created() {},
  mounted() {
    // console.log(this.$attrs)
    // this.LoadAccountConfigData();
    this.$refs.vueform.setFormValue(this.formObj);
  },
  methods: {
    LoadAccountConfigData(ParamType) {
      let params = { type: ParamType };
      LoadAccountConfigAxios(params)
        .then((res) => {
          // this.AccountData = res.data;
        })
        .catch((err) => {
          console.log("请求失败：" + err.status + "," + err.statusText);
        });
    },
    buttonClick(key, btnItem) {
      if (key == "button_1") {
        if (btnItem.action == "submit") {
          // console.log(234, key, btnItem);
          this.$refs.vueform.$refs.forms.validate((valid) => {
            if(valid){
            console.log(43, this.formObj);
            }
          });
        }
      }
    },
  },
};
</script>

<style>
</style>